function [out]=fill_holes_in_binary_vec(in,win)

out=in;
for ind=win+1:length(in)-win
    if abs(mean(in(ind-win:ind-1))-in(ind))>0.5 && abs(mean(in(ind+1:ind+win))-in(ind))>0.5
        out(ind)=~in(ind);
    end
end